<?php
require_once 'application/library/db/gcBasicDao.php';
require_once 'application/constant/dbConstant.php';

class dao_T_EC_M_GOODS_REALATED_SUPPLIERDao extends gcBasicDao {
    protected $_table = "T_EC_M_GOODS_REALATED_SUPPLIER";
    public function pbGetSupplierNo($strGoodsNo) {
        $sql = "select SUPPLIER_NO from T_EC_M_GOODS_REALATED_SUPPLIER 
                    where GOODS_NO = :GoodsNo ";
        $parameter = array("GoodsNo" => $strGoodsNo);
        $arrSupplierNo = $this->select($sql, $parameter, dbReturnType::COL);
        return $arrSupplierNo;
    }

    public function pbGetSupplierInfo($strGoodsNo) {
        $sql = "select A.SUPPLIER_NO, B.SUPPLIER_NAME  from T_EC_M_GOODS_REALATED_SUPPLIER as A left join T_AD_M_SUPPLIER as B on 
                    A.SUPPLIER_NO = B.SUPPLIER_NO where GOODS_NO = :GoodsNo ";
        $parameter = array("GoodsNo" => $strGoodsNo);
        $arrSupplierInfo = $this->select($sql, $parameter, dbReturnType::ALL);
        return $arrSupplierInfo;
    }
    public function pbGoodsRealatedSupplierDelete($strGoodsNo) {
        $sql = "delete from T_EC_M_GOODS_REALATED_SUPPLIER where GOODS_NO = :GoodsNo ";
        $parameter = array("GoodsNo" => $strGoodsNo);
        $this->delete($sql, $parameter);
    }

    public function pbGoodsRealatedSupplierInsert($strSupplier, $strGoodsNo) {
        $sql = "insert into  T_EC_M_GOODS_REALATED_SUPPLIER (GOODS_NO,SUPPLIER_NO)
                            values(:GoodsNo, :Supplier) ";
        $parameter = array("GoodsNo" => $strGoodsNo,
                            "Supplier" =>$strSupplier);
         $this->insert($sql, $parameter);
    }
}